<template>
    <body style="width: 500px;">
    <div id="qqq"    >
      <div id="qrCode" ref="qrCodeDiv"></div>
      <div style=" float: right;width: 400px; text-align:left; margin: 20px;font-size: 10px;padding-top: 20px;">
        <label style="width: 180px;text-align: left; margin-top: 20px; font-size: 32px; line-height: 60px;">  焊口编号:{{ hkcode}}</label><br/>
        <label style="width: 180px;text-align: left; margin-top: 20px;font-size: 32px; line-height: 60px;">  焊接工艺规程:{{ craftsNumber }}</label><br/>
        <label style="width: 180px;text-align: left;margin-top: 20px; font-size: 32px;line-height: 60px;">  施工单位:{{sgdw }}</label><br/>
 
        <label style="width: 180px;text-align: left; margin-top: 20px; font-size: 32px; line-height: 60px;">  预制日期:{{nowTime}}</label><br></br>
    </div>
    </div>
   
    </body>
</template>

<script>
import QRCode from 'qrcodejs2';
export default {
  name: "qrCode",
  data() {
    return {
        nowTime: null,
            hkcode:"",
            craftsNumber:"",
            xmbh:"",
            sgdw:"",
            teamCode:"",
            siteCode:"",
            layerType:"",
           

    }
  },
  mounted: function () {
    this.hkcode = this.$route.params.hkcode
    this.craftsNumber = this.$route.params.craftsNumber
    this.sgdw = this.$route.params.sgdw
    this.xmbh = this.$route.params.xmbh
    this.teamCode = this.$route.params.teamCode
    this.siteCode = this.$route.params.siteCode
    this.layerType = this.$route.params.layerType
    this.$nextTick(function () {
      this.bindQRCode( );
    })
    this.getNowTime(); //调用函数
  },
  methods: {
  
    getNowTime() {
           var date = new Date();
           var sign2 = ":";
           var year = date.getFullYear() // 年
           var month = date.getMonth() + 1; // 月
           var day = date.getDate(); // 日
           var hour = date.getHours(); // 时
           var minutes = date.getMinutes(); // 分
           var seconds = date.getSeconds() //秒
           var weekArr = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期天'];
           var week = weekArr[date.getDay()];
            // 给一位数的数据前面加 “0”
           if (month >= 1 && month <= 9) {
                month = "0" + month;
           }
            if (day >= 0 && day <= 9) {
                day = "0" + day;
            }
            if (hour >= 0 && hour <= 9) {
             hour = "0" + hour;
             }
           if (minutes >= 0 && minutes <= 9) {
              minutes = "0" + minutes;
            }
           if (seconds >= 0 && seconds <= 9) {
              seconds = "0" + seconds;
          }
      this.nowTime =  year + "-" + month + "-" + day  ;
     } ,
    bindQRCode: function () {
    
            let ax="{\"PIPE\":{\"weldCode\":\""+this.hkcode+"\",\"teamCode\":\""+this.teamCode+"\",\"siteCode\":\""+this.teamCode+"\",\"process\":\""+this.craftsNumber+"\",\"layerType\":\""+this.layerType+"\"}}" 
            new QRCode(this.$refs.qrCodeDiv, {
            text: ax,
            width: 360,
            height: 360,
            colorDark: "#333333", //二维码颜色
            colorLight: "#ffffff", //二维码背景色
            correctLevel: QRCode.CorrectLevel.L//容错率，L/M/H
        })
 
     
    }
  }
}
</script>
<style lang='less'>
#qqq {
  background-color: #ffffff;
  width:960px;
  height:410px;
  position:absolute;
  margin: 0 auto; /*水平居中*/
  top: 30%;
 left: -230px;
  -moz-transform:rotate(90deg);
  -webkit-transform:rotate(90deg);
   filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);    
 
  
}
 
#qrCode {
  display: inline-block;
  margin: 0 auto; /*水平居中*/
  position: relative;
  margin: 20px;
 
  img {
    width: 360px;
    height: 360px;
    background-color: #fff; //设置白色背景色
    padding: 6px; // 利用padding的特性，挤出白边
  }

}
</style> 